export default {
  namespaced: true,
  state: {
    readHistory: [],
  },
  getters: {},
  mutations: {
    setReadHistory: (state, {
      bookInfo,
      currentIndex,
      readHistory
    }) => {
      if (bookInfo && currentIndex) {
        state.readHistory = [{
          bookInfo,
          currentIndex
        }, ...state.readHistory.filter(item => item.sourceUuid != bookInfo.sourceUuid)];
        localStorage.setItem("readHistory", JSON.stringify(state.readHistory));
      } else {
        state.readHistory = readHistory;
      }
    },
  },
  actions: {},
  modules: {}
}